﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;
using System.Data;

namespace Bussiness_Objects
{
    /// <summary>
    /// Thong tin table DOCGIA
    /// ---DOCGIA(MaDocGia,MaLoaiDocGia,HoTen,NgaySinh,DiaChi,Email,NgayLapThe,NgayHetHan,TongNo)
    /// </summary>
    public class DocGia : BusinessObjects
    {
        public DocGia() 
        {

        }

        public DocGia(int _maDG,int _maLDG, string _hoTen, string _ngSinh,
                      string _diaChi, string _email, string _ngLapThe, string _ngHetHan, long _tgNo)
        {
            MaDocGia = _maDG;
            MaLoaiDocGia = _maLDG;
            HoTen = _hoTen;
            NgaySinh = _ngSinh;
            DiaChi = _diaChi;
            Email = _email;
            NgayLapThe = _ngLapThe;
            NgatHetHan = _ngHetHan;
            TongNo = _tgNo;
        }

        public override void SetParameterInsert()
        {
            parms = new object[9];
            SqlParameter _parm = new SqlParameter();
            _parm.ParameterName = option;
            _parm.DbType = DbType.Int32;
            _parm.Value = 0;
            parms[0] = _parm;           

            _parm = new SqlParameter();
            _parm.ParameterName = parMaDocGia;
            _parm.DbType = DbType.Int32;
            _parm.Value = 0;
            parms[1] = _parm;

            _parm = new SqlParameter(parMaLoaiDocGia, MaLoaiDocGia);
            parms[2] = _parm;

            _parm = new SqlParameter(parHoTen, HoTen);
            parms[3] = _parm;

            _parm = new SqlParameter(parNgaySinh, NgaySinh);
            parms[4] = _parm;

            _parm = new SqlParameter(parDiaChi, DiaChi);
            parms[5] = _parm;

            _parm = new SqlParameter(parEmail, Email);
            parms[6] = _parm;

            _parm = new SqlParameter(parNgayLapThe, NgayLapThe);
            parms[7] = _parm;

            _parm = new SqlParameter(parTongNo, TongNo);
            parms[8] = _parm;
        }

        public override void SetParameterUpdate()
        {
            SetParameterInsert();
            SqlParameter _parm = new SqlParameter(option, 1);
            parms[0] = _parm;

            _parm = new SqlParameter(parMaDocGia, MaDocGia);
            parms[1] = _parm;
        }

        public void SetParameterUpdateTongNo()
        {
            parms = new object[2];
            SqlParameter _parm = new SqlParameter(parMaDocGia, MaDocGia);
            parms[0] = _parm;

            _parm = new SqlParameter(parTongNo, TongNo);
            parms[1] = _parm;
        }

        public void SetParameterDelete()
        {
            parms = new object[1];
            SqlParameter _parm = new SqlParameter(parMaDocGia, MaDocGia);
            parms[0] = _parm;
        }

        public void SetParameterSelectID()
        {
            SetParameterDelete();
        }

        private const string option = "@option"; // Option = 0 Insert & MaDocGia = 0 -- Option = 1 Update

        public int MaDocGia { get; set; }
        private const string parMaDocGia = "@MaDocGia";

        public int MaLoaiDocGia { get; set; }
        private const string parMaLoaiDocGia = "@MaLoaiDocGia";

        public string HoTen { get; set; }
        private const string parHoTen = "@HoTen";

        public string NgaySinh { get; set; }
        private const string parNgaySinh = "@NgaySinh";

        public string DiaChi { get; set; }
        private const string parDiaChi = "@DiaChi";

        public string Email { get; set; }
        private const string parEmail = "@Email";

        public string NgayLapThe { get; set; }
        private const string parNgayLapThe = "@NgayLapThe";

        public string NgatHetHan { get; set; }
        private const string parNgayHetHan = "@NgayHetHan";

        public long TongNo { get; set; }
        private const string parTongNo = "@TongNo";
    }
}
